using System;
using System.Collections.Generic;
using System.Text;
using ICSharpCode.TextEditor;

namespace RideMe.Presentation
{
    public class ActiveDocumentInformation
    {

        public event EventHandler<SwitchTabEventArgs> TabSwitched;

        protected virtual void OnTabSwitched(SwitchTabEventArgs e)
        {
            if (TabSwitched != null)
            {
                TabSwitched(this, e);
            }
        }

        private static readonly object _padlock = new object();
        private static ActiveDocumentInformation _instance;

        /// <summary>
        /// Gets the instance of this singelton object. If the
        /// object isn't instantiated it, tries to get the options
        /// that may have been previously saved.
        /// </summary>
        /// <value>The instance.</value>
        public static ActiveDocumentInformation Instance
        {
            get
            {
                lock (_padlock)
                {
                    if (_instance == null)
                    {
                        _instance = new ActiveDocumentInformation();
                    }
                }
                return _instance;
            }
        }

        private List<TextEditorControl> _openTextEditors;

        public List<TextEditorControl> OpenTextEditors
        {
            get 
            {
                if (_openTextEditors == null)
                {
                    _openTextEditors = new List<TextEditorControl>();
                }
                return _openTextEditors; 
            }
            set { _openTextEditors = value; }
        }
	
        private TextEditorControl _activeTextEditor;

        public TextEditorControl ActiveTextEditor
        {
            get { return _activeTextEditor; }
            set { _activeTextEditor = value; }
        }

        public void SwitchTab(TextEditorControl desiredTextEditor)
        {
            OnTabSwitched(new SwitchTabEventArgs(desiredTextEditor));
        }

    }
}
